import path from "path"
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(),
    AutoImport({
        imports: [
        'vue', // 自动导入 Vue 相关 API
        'vue-router', // 自动导入 Vue Router 相关 API
        ],
    resolvers: [ElementPlusResolver()],
  }),
  Components({
    resolvers: [ElementPlusResolver()],
  })
],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src")
    }
  },
  server: {
    proxy: {
      "/api": {
        target: "http://ceshi13.dishait.cn/admin", //这对应的是baseUrl
        changeOrigin: true,
        rewrite: (path:any) => path.replace(/^\/api/, ""), // 请求的时候去掉/api
      },
    },
  },
})
